package flc.ast.adapter;

import android.graphics.Color;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ImageUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyDocTypeBean;
import flc.ast.bean.MyRecentFileBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class RecentFileAdapter extends StkProviderMultiAdapter<MyRecentFileBean> {

    public RecentFileAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new RecentFileProvider());
    }

    private class RecentFileProvider extends BaseItemProvider<MyRecentFileBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_recent_file;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyRecentFileBean bean) {
            if (ImageUtils.isImage(bean.getPath())) {
                Glide.with(baseViewHolder.itemView).load(bean.getPath()).into((ImageView) baseViewHolder.getView(R.id.ivRecentFileItemImg));
            } else {
                baseViewHolder.setImageResource(R.id.ivRecentFileItemImg, R.drawable.apdf);
            }
            baseViewHolder.setText(R.id.tvRecentFileItemName, bean.getName());
            baseViewHolder.setText(R.id.tvRecentFileItemDate, bean.getDate() + " " + bean.getSize());
        }
    }

}
